package tmp.antlr;

import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;

import a6.MySqlLexer;
import a6.MySqlParser;
import a6.MySqlParser.SqlContext;


public class Test4 {

	public static void main(String[] args) throws Exception{
		run("select user_id,name from user_info where user_id=1");

	}

	public static void run(String expr)throws Exception{
		ANTLRInputStream in = new ANTLRInputStream(expr);
		
		MySqlLexer lexer = new MySqlLexer(in);
		
		CommonTokenStream tokens = new CommonTokenStream(lexer);
		
		MySqlParser exprParser = new MySqlParser(tokens);
		SqlContext sqlContext = exprParser.sql();
		System.out.println(sqlContext.getText());
		
		System.out.println(sqlContext.ID().get(0).getText());
		System.out.println(sqlContext.ID().get(1).getText());
		System.out.println(sqlContext.ID().get(2).getText());
	}
}
